/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sevent.service;

import com.sevent.model.dao.T02UserDao;
import com.sevent.util.Util;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 
 * @author enriquer
 */
@Service
public class UserServiceImpl implements UserService {

    private static final Log log = LogFactory.getLog(UserServiceImpl.class);
    //
    @Autowired()
    private T02UserDao t02UserDao;

    public void addUser(Map<String, Object> params) {

        try {

            String password = (String)params.get("txtPassword");
            password = Util.md5(password);
            System.out.println(params.get("txtPassword") + " " + password);
            
            Map<String, Object> user = new HashMap<String, Object>();
            user.put("t02_firstname", params.get("txtFirstName"));
            user.put("t02_lastname", params.get("txtLastName"));
            user.put("t02_email", params.get("txtEmail"));
            user.put("t02_password", password);
            user.put("t02_firstname", params.get("txtFirstName"));
            user.put("t02_typeid", "01");
            user.put("t02_status", "0");

            if (log.isDebugEnabled()) {
                log.debug(user);
            }

            t02UserDao.insert(user);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            throw new RuntimeException(ex);
        }

    }

    public void findByLogin(String login) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void saveUser(Map params) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
